package com.ruoyi.appService.careeranchor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.careeranchor.domain.ZTestCareeranchor;
import com.ruoyi.appService.careeranchor.service.IZTestCareeranchorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职业锚测试题Controller
 * 
 * @author anjiao
 * @date 2025-05-10
 */
@RestController
@RequestMapping("/mentalTest/careeranchor")
public class ZTestCareeranchorController extends BaseController
{
    @Autowired
    private IZTestCareeranchorService zTestCareeranchorService;

    /**
     * 查询职业锚测试题列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZTestCareeranchor zTestCareeranchor)
    {
        startPage();
        List<ZTestCareeranchor> list = zTestCareeranchorService.selectZTestCareeranchorList(zTestCareeranchor);
        return getDataTable(list);
    }

//查询所有试题
    @GetMapping("/listAll")
    public TableDataInfo listAll(ZTestCareeranchor zTestCareeranchor)
    {
        List<ZTestCareeranchor> list = zTestCareeranchorService.selectZTestCareeranchorList(zTestCareeranchor);
        return getDataTable(list);
    }





    /**
     * 导出职业锚测试题列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:export')")
    @Log(title = "职业锚测试题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZTestCareeranchor zTestCareeranchor)
    {
        List<ZTestCareeranchor> list = zTestCareeranchorService.selectZTestCareeranchorList(zTestCareeranchor);
        ExcelUtil<ZTestCareeranchor> util = new ExcelUtil<ZTestCareeranchor>(ZTestCareeranchor.class);
        util.exportExcel(response, list, "职业锚测试题数据");
    }


    /**
     * 获取职业锚测试题详细信息
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zTestCareeranchorService.selectZTestCareeranchorById(id));
    }

    /**
     * 新增职业锚测试题
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:add')")
    @Log(title = "职业锚测试题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZTestCareeranchor zTestCareeranchor)
    {
        return toAjax(zTestCareeranchorService.insertZTestCareeranchor(zTestCareeranchor));
    }

    /**
     * 修改职业锚测试题
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:edit')")
    @Log(title = "职业锚测试题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZTestCareeranchor zTestCareeranchor)
    {
        return toAjax(zTestCareeranchorService.updateZTestCareeranchor(zTestCareeranchor));
    }

    /**
     * 删除职业锚测试题
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:careeranchor:remove')")
    @Log(title = "职业锚测试题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zTestCareeranchorService.deleteZTestCareeranchorByIds(ids));
    }
}
